package com.lsfb.signln.Location.TaskMsg.MsgDetails;

import android.content.Intent;
import android.widget.TextView;

import com.lsfb.signln.Login.LoginActivity;
import com.lsfb.signln.R;
import com.lsfb.signln.Utils.LittleUtils;
import com.lsfb.signln.Utils.URLString;
import com.zgscwjm.lsfbbasetemplate.Event.EventAnnotation;
import com.zgscwjm.lsfbbasetemplate.LsfbActivity;
import com.zgscwjm.lsfbbasetemplate.annotation.ContentView;
import com.zgscwjm.lsfbbasetemplate.annotation.ViewInject;
import com.zgscwjm.lsfbbasetemplate.internet.BaseInternet;
import com.zgscwjm.lsfbbasetemplate.utils.T;

import java.util.HashMap;

/**
 * 消息详情
 * Created by Administrator on 2018/1/31 0031.
 */
@ContentView(R.layout.aty_msg_details)
public class MsgDetailsActivity extends LsfbActivity {
    /**
     * 通知内容
     */
    @ViewInject(R.id.aty_message_tv_content)
    private TextView tv_content;

    /**
     * 通知时间
     */
    @ViewInject(R.id.aty_message_tv_time)
    private TextView tv_time;
    private String id;


    @Override
    public void initView() {
        LittleUtils.setsimpletitlebar(this, "通知详情");

        if (getIntent().getStringExtra("id") != null) {
            id = getIntent().getStringExtra("id");
        } else {
            T.showShort(this, "获取数据异常");
            finish();
            return;
        }

        getMsgDetail();
    }

    private void getMsgDetail() {
        HashMap hashMap = new HashMap();
        hashMap.put("id", id);
        new BaseInternet().getData_Get(URLString.SHOWMSGDETAILS, hashMap, MessageDetailBean.class, new MessageDetailEvent<MessageDetailBean>(), true, false);
    }

    @EventAnnotation
    public void eventResult(MessageDetailEvent<MessageDetailBean> event) {
        switch (event.getCode()) {
            case 200:
                tv_content.setText(event.getData().getContent());
                tv_time.setText(event.getData().getTime());
                break;
            case 1006:
                T.showShort(this, "您的账号已在其它设备登录，请重登录");
                LittleUtils.exit(this);
                startActivity(new Intent(this, LoginActivity.class));
                break;
            default:
                T.showShort(this, event.getMsg());
                break;
        }
    }

    @Override
    public void initEvent() {

    }

    @Override
    public void initData() {

    }
}
